This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
## Load the library
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(maps)
## Warning: package 'maps' was built under R version 3.3.3
library(reshape2)
library(leaflet)
library(ggplot2)
library(ggmap)
## Warning: package 'ggmap' was built under R version 3.3.3
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
library(readr)
Data <- read_delim("E:/KPMG/Data/Data.csv",
";", escape_double = FALSE, trim_ws = TRUE)
## Parsed with column specification:
## cols(
## .default = col_character(),
## LoanBalance = col_double(),
## InterestRate = col_double(),
## NIM = col_double(),
## CreditRating = col_integer(),
## InterestIncome = col_double(),
## LTV = col_double(),
## MortgageYears = col_integer(),
## PropertyValue = col_double(),
## AnnualPYMT = col_double(),
## MaturityDate = col_integer(),
## BookingDate = col_integer(),
## LastValuationDate = col_integer(),
## ValuationAgeYears = col_double(),
## CreditRatingMovement = col_integer(),
## AddressLatitude = col_double(),
## AddressLongitude = col_double(),
## ValueInArrears = col_double(),
## DaysInArrears = col_integer(),
## `%_HousePriceMovement` = col_double(),
## UpdatedPropertyValue = col_double()
## )
## See spec(...) for full column specifications.
View(Data)
us_weather_df <- data.frame(Data)
weatherIcon <- makeIcon(
iconUrl = "./fig/weather.png",
iconWidth = 30,
iconHeight = 30
)
popupInfo <- paste(us_weather_df[['ContractRef']],
", ",
us_weather_df[['LoanBalance']],
"<br>",
"Average January Temp in F: ",
us_weather_df[['DefaultedLoans']],
"<br>",
"Credit Rating: ",
us_weather_df[['CreditRating']],
"<br>",
"LTV: ",
us_weather_df[['LTV']],
"<br>",
"Property Value: ",
us_weather_df[['PropertyValue']],
sep='')
us_mainland_temp <- leaflet(us_weather_df) %>%
setView(-93.65, 42.0285, zoom = 4) %>%
addTiles() %>%
addMarkers(Data$AddressLongitude, Data$AddressLatitude, popup= ~ popupInfo,
options = popupOptions(closeButton = TRUE),
clusterOptions = markerClusterOptions(),
icon = weatherIcon)
us_mainland_temp